package com.qjc.demo.train.divide;

/**
 * @ClassName: CharUpCase
 * @Description: 分治算法：小写转大写
 * @Author: qjc
 * @Date: 2022/5/4 11:08 AM
 */
public class CharUpCase {

    public static char[] toUpCase(char[] chs, int i) {
        if (i >= chs.length) {
            return chs;
        }
        chs[i] = toUpCaseUnit(chs[i]);
        return toUpCase(chs, i + 1);
    }

    public static char toUpCaseUnit(char a) {
        int n = a;
        if (n < 97 || n > 122) {
            return a;
        }
        return (char) (n - 32); // 转大写
    }

    public static void main(String[] args) {
        String ss = "abcde";
        System.out.println(toUpCase(ss.toCharArray(), 0));
    }

}
